package entity;

import static javax.persistence.GenerationType.IDENTITY;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Klasa User povezuje entitet USER u bazi podataka i sinhronizuje
 * 
 * @author rigo
 *
 */
@Entity
@Table(name="USER")
public class User implements Serializable{
	private static final long serialVersionUID = 8614067173031292848L;

	@Id
	@GeneratedValue(strategy=IDENTITY) 
	@Column(name="US_ID", unique=true, nullable=false)
	protected Integer userId;

	@Column(name="US_EMAIL", unique=true, nullable=false)
	protected String email;
	
	@Column(name="US_PASSWORD", unique=false, nullable=false)
	protected String password;
	
	@Column(name="US_FIRSTNAME", unique=false, nullable=false)
	protected String firstName;

	@Column(name="US_LASTNAME", unique=false, nullable=false)
	protected String lastName;
	
	@Column(name="US_PHNONE", unique=false, nullable=false)
	protected String phone;

	@Column(name="US_AVATAR", unique=false, nullable=true)
	protected String avatar;

	@Column(name="US_TYPE", unique=false, nullable=false)
	protected Character type;
	
	@Column(name="US_ACTIVE", unique=false, nullable=false)
	protected Boolean active;	
	
	@Column(name="US_DELETED", unique=false, nullable=false)
	protected Boolean deleted;

	@Column(name="US_GOALS", unique=false, nullable=true)
	protected Integer goals;
	
	@OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.EAGER, mappedBy="user")
	protected Set<Comment> comment = new HashSet<Comment>();

	@OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.EAGER, mappedBy="userChanged")
	protected Set<Comment> commentChange = new HashSet<Comment>();
	
	@OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.EAGER, mappedBy="mvp")
	protected Set<FootballMatch> matchMvp = new HashSet<FootballMatch>();
	
	@OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.EAGER, mappedBy="user")
	protected Set<Players> players = new HashSet<Players>();
	
	public Set<Comment> getComment() {
		return comment;
	}

	public void setComment(Set<Comment> comment) {
		this.comment = comment;
	}

	public Set<Comment> getCommentChange() {
		return commentChange;
	}

	public void setCommentChange(Set<Comment> commentChange) {
		this.commentChange = commentChange;
	}

	public Integer getUserId() {
		return userId;
	}

	public String getEmail() {
		return email;
	}

	public String getPassword() {
		return password;
	}

	public String getFirstName() {
		return firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public String getPhone() {
		return phone;
	}

	public String getAvatar() {
		return avatar;
	}

	public Character getType() {
		return type;
	}

	public Boolean getActive() {
		return active;
	}

	public Boolean getDeleted() {
		return deleted;
	}

	public void setUserId(Integer userId) {
		this.userId = userId;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public void setAvatar(String avatar) {
		this.avatar = avatar;
	}

	public void setType(Character type) {
		this.type = type;
	}

	public void setActive(Boolean active) {
		this.active = active;
	}

	public void setDeleted(Boolean deleted) {
		this.deleted = deleted;
	}

	public Integer getGoals() {
		return goals;
	}

	public void setGoals(Integer goals) {
		this.goals = goals;
	}

}
